package org.gxuwz.core.action;

import java.util.List;

import org.gxuwz.core.entity.TArea;
import org.gxuwz.core.entity.TInstitution;
import org.gxuwz.core.service.IAreaService;
import org.gxuwz.core.service.IInstitutionService;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class InstitutionAction extends ActionSupport implements ModelDriven<TInstitution>{
	TInstitution inst = new TInstitution();
    List<TInstitution> list;
	String agencode;
	String agenname;
	
	@Autowired
    IInstitutionService instService;
	
	@Override
	public TInstitution getModel() {
		// TODO Auto-generated method stub
		return inst;
	}
	
	public String list() {
		list = instService.getAll(agenname, agencode);
		return "list";
	}
	
	public String getByAreaName(){
		inst = instService.getByAgenName(agenname);
		return "list";
	}

	public String edit(){
		inst = instService.getByAgenName(agenname);
		return "edit";
	}
	
	public String update(){
		instService.update(inst);
		return list();
	}
	
	public String delete(){
		inst = instService.getByAgenName(agenname);
		instService.delete(inst);
		return this.list();
	}

	public TInstitution getInst() {
		return inst;
	}

	public void setInst(TInstitution inst) {
		this.inst = inst;
	}

	public List<TInstitution> getList() {
		return list;
	}

	public void setList(List<TInstitution> list) {
		this.list = list;
	}

	public String getAgencode() {
		return agencode;
	}

	public void setAgencode(String agencode) {
		this.agencode = agencode;
	}

	public String getAgenname() {
		return agenname;
	}

	public void setAgenname(String agenname) {
		this.agenname = agenname;
	}

	public IInstitutionService getInstService() {
		return instService;
	}

	public void setInstService(IInstitutionService instService) {
		this.instService = instService;
	}
	
	
}
